Satellite: saving 配置服务器
[pkm.git] / pages / Async Rails Plugin.textile
blob734c88a722318577ec982271f0b267afa76dccd4
1 Homepage: http://github.com/lassej/async/tree/master
3 安装&初始化:
4 {{{
5 script/plugin install git://github.com/lassej/async.git
6 script/generate async
7 rake db:migrate
9 script/async
10 #/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- ruby-debug (LoadError)
11 #       from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
12 #       from script/async:4
13 sudo gem install ruby-debug
14 #Password:
15 #Building native extensions.  This could take a while...
16 #Building native extensions.  This could take a while...
17 #Successfully installed columnize-0.3.0
18 #Successfully installed linecache-0.43
19 #Successfully installed ruby-debug-base-0.10.3
20 #Successfully installed ruby-debug-0.10.3
21 #4 gems installed 
22 script/async
23 }}}
25 使用:
27 Controller:
28 {{{
29 @async_task = LinksController.async( :site_explore, :args => [@link])
30 }}}
32 View:
33 {{{
34 task_checker = setInterval(function(){check_task(<%= @async_task.id -%>)}, 1000);
36 function check_task(id) {
37         $.ajax({ method: 'get',
38                 url : '/links/task/' + id,
39                 dataType : 'json',
40                 success: list_links
41         });
44 function list_links(data) {
45         $("#list").html(data[2][0].toString());
46         if (task_checker) clearInterval(task_checker);
49 }}}